<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.LinkedHashMap" %>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%--//根据用户id获取分部和街道--%>
<%
    String loginid = request.getParameter("loginid");
%>

<%
//    RecordSet rs = new RecordSet();

    String sql = "select * from (select hrm.id,hrm.lastname,hrm.subcompanyid1,hsub.subcompanyname,hrm.departmentid,hdept.departmentname from hrmresource hrm  left join hrmsubcompany hsub on hsub.id = hrm.subcompanyid1 left join HrmDepartment hdept on hdept.id = hrm.departmentid) t where t.id = '"+loginid+"'";

    rs.executeSql(sql);
    if (rs.next()){
        //获取分部和街道信息
        String id = Util.null2String(rs.getString("id"));
        String lastname = Util.null2String(rs.getString("lastname"));
        String subcompanyid1 = Util.null2String(rs.getString("subcompanyid1"));
        String subcompanyname = Util.null2String(rs.getString("subcompanyname"));
        String departmentid = Util.null2String(rs.getString("departmentid"));
        String departmentname = Util.null2String(rs.getString("departmentname"));

        Map<String,String> map = new LinkedHashMap<String,String>();
        map.put("id",id);
        map.put("lastname",lastname);
        map.put("subcompanyid1",subcompanyid1);
        map.put("subcompanyname",subcompanyname);
        map.put("departmentid",departmentid);
        map.put("departmentname",departmentname);

//        System.out.println(id+"======================");

        //转换json
        net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(map);
        response.getWriter().write(jsonObject.toString());
    }
%>